home *** CD-ROM | disk | FTP | other *** search
- title TIMERS01 -- High Resolution Timer Setup
- page 60,120
-
- name TIMERS01 ; module
-
- comment | Module Specifications
-
- Copyright: None.
-
- Environment: IBM PC, tested under DOS 2.0.
-
- Segmentation: Program segment CODE, public, byte aligned, class ''.
-
- Public symbols and external references: See Symbols section of listing.
-
- Link requirements: None, standalone subroutine.
-
- Program derived from: None.
-
- Original code by: Bob Smith and Tom Puckett, October 1983.
-
- Modifications by: None.
-
-
- Procedure Specifications
-
- Public Procedure TIMERS01 -- High Resolution Timer Setup
-
- This is a subroutine to set up Counter 0 of the 8253 to run in Mode 2.
- It normally runs in Mode 3, which makes its residual count values
- useless for high resolution timing purposes since in this mode it counts
- down by twos, with two countdowns per cycle. In Mode 2 there is a
- single countdown per cycle, by ones, so the residual count values are
- meaningful. (See routine TIMERR02 for recovering timing information.)
-
- Assumptions: Counter 0 is to be set to normal count of 65536.
-
- Linkage: Near call and return.
-
- Arguments: None.
-
- Effects: Counter 0 set to mode 2, count 65536, binary.
-
- Results: Flags destroyed.
-
- Return conditions: None.
-
- Limitations: None.
-
- |
- page
-
- code segment public byte
- assume cs:code
-
- ; equates....
-
- timer_0 equ 40h ; 8253 counter 0 port
- timer_ctl equ 43h ; 8253 control port
- timer_set equ 00110100b ; 8253 Counter 0, set LOB/HOB, mode 2, binary
-
- public TIMERS01
- TIMERS01 proc near ; see specifications at head of listing
-
- push ax ; preserve
- push cx
-
- mov al,timer_set
- out timer_ctl,al ; set Counter 0 parameters, prime load trigger
- xor al,al ; zero will give full count of 65536
- nop ; insure 5 clocks for 8253 recovery time
- out timer_0,al ; load low order byte
- nop ; 8253 recovery time
- nop ; " " "
- out timer_0,al ; load high order byte
-
- mov cx,20000 ; must be sure previous countdown has completed,
- loop: loop loop ; so spin here 70 milliseconds to guarantee it
-
- pop cx ; restore
- pop ax
- ret
-
- TIMERS01 endp
-
- code ends ; end code segment
-
- end ; end module